<?php
$awal = datefmysql($params['awal']);
$akhir = datefmysql($params['akhir']);
$adik_asuh = $params['adikAsuh'];
$id_adik_asuh = $params['idAdikAsuh'];
$namaFile = 'keuangan_adik_asuh.xls';

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");

// header untuk nama file
header("Content-Disposition: attachment;
                filename=".$namaFile."");

header("Content-Transfer-Encoding: binary ");
?>
<html>
    <head>
        <title>Cetak Laporan Keuangan Adik Asuh</title>
        <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>system/css/style2.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>system/css/tabel.css" />
    </head>
    <body>
        <table border="0">
            <tr bgcolor="#cccccc">
                <td colspan="11" align="center"><strong><font size="+1">Laporan Keuangan Adik Asuh</font></strong></td>
            </tr>
            <tr bgcolor="#cccccc">
                <td colspan="11" align="center"><strong><font size="+1">Periode <?php echo indo_tgl($awal)?> s.d <?php echo indo_tgl($akhir)?></font></strong></td>
            </tr>
            <?php
              if($adik_asuh != ''){
            ?>
            <tr bgcolor="#cccccc">
                <td colspan="11" align="center"><strong><font size="+1">Nama Adik Asuh : <?php echo "$adik_asuh";?></font></strong></td>
            </tr>
            <?php
              }
            ?>
        </table>
        <div class="data-list">
                <table class="tabel">
                <tr>
                    <th style="width:3%">No</th>
                    <th style="width:5%">Tanggal</th>
                    <th style="width:10%">Petugas</th>
                    <th style="width:10%">Adik Asuh</th>
                    <th>Sekolah</th>
                    <th style="width:5%">Kelas</th>
                    <th style="width:8%">Tahun Ajaran</th>
                    <th>Keterangan</th>
                    <th style="width:8%">Debet (Rp.)</th>
                    <th style="width:8%">Kredit (Rp.)</th>
                    <th style="width:8%">Saldo (Rp.)</th>
                </tr>
                <?php
                  $no = 1;
                  foreach ($data as $row){
                ?>
                <tr class="<?php echo ($no%2)?"even":"odd"?>">
                    <td align="center"><?php echo $no++;?></td>
                    <td><?php echo datefmysql($row['tanggal']);?></td>
                    <td><?php echo $row['petugas'];?></td>
                    <td><?php echo $row['adik_asuh'];?></td>
                    <td><?php echo $row['sekolah'];?></td>
                    <td><?php echo $row['kelas'];?></td>
                    <td><?php echo $row['tahun_ajaran']." ".$row['semester'];?></td>
                    <td><?php echo $row['keterangan'];?></td>
                    <td style="text-align: right">
                       <?php 
                          echo ($row['debet']!=0)?rupiah($row['debet']):"-";
                       ?>
                    </td>
                    <td style="text-align: right">
                       <?php 
                          echo ($row['kredit']!=0)?rupiah($row['kredit']):"-";
                       ?>
                    </td>
                    <td align="right"><?php echo rupiah($row['saldo']);?></td>
                </tr>
                <?php
                  }
                ?>
            </table>
        </div>
    </body>
</html>   